import 'elix/define/Dialog.js'
import pwsdHtml from './msgalert.html'

const $click = (element, handler) => {
    element.addEventListener('click', handler)
    element.addEventListener('touchend', handler)
  }
export class msginfo extends HTMLElement{
    constructor(svgShow,init){
        super()
        const template = document.createElement('template')
        template.innerHTML = pwsdHtml
        this.svgShow = svgShow
        this.svgShow.$svgShow.append(template.content.cloneNode(true))
        this.$docDialog = this.svgShow.$svgShow.querySelector("#msg_box")
        this.$container = this.svgShow.$svgShow.querySelector("#msginfo")
        this.init()
    }

    open(msg){
        this.alertMsg(msg)
        this.$docDialog.open()
    }

    close(){
        this.$docDialog.close()
        this.svgShow.loadingpage.close()
    }

    alertMsg(msg){
        this.$container.textContent = msg
    }

    init(){
        this.$cancleBtn = this.svgShow.$svgShow.querySelector('#msgconf')
        var that = this
        $click(this.$cancleBtn, function () {
            that.close()
        })
    }

}
customElements.define('msginfo-dialog', msginfo)

